<?php
/**
 * Created by PhpStorm
 * User: Jhinwy
 * Date: 5/27/24
 * Time: 2:07 PM
 */

namespace App\Http\Controllers\Admin;

use App\Services\OrderService;
use Illuminate\Http\Request;
use App\Http\Controllers\ResourceController;

class OrderController extends ResourceController
{
    protected $service;

    public function __construct(OrderService $service)
    {
        $this->service = $service;
    }


    /**
     * 获取订单列表
     *
     * @param Request $request
     * @return mixed
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function getList(Request $request)
    {
        return $this->responseWithSuccess($this->service->getOrderList($request->post()));
    }


    /**
     * 获取订单激活码列表
     *
     * @param Request $request
     * @return mixed
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function getCodeList(Request $request)
    {
        return $this->responseWithSuccess($this->service->getCodeList($request->post()));
    }


    /**
     * 激活账号
     *
     * @param Request $request
     * @return mixed
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function activeAccount(Request $request)
    {
        $result = $this->service->activeAccount($request->post());
        if (is_string($result)) {

            return $this->responseWithError($result);
        }

        return $result ? $this->responseWithSuccess() : $this->responseWithError();
    }
}
